﻿<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>OMS后台管理系统</title>
	
	<link rel="shortcut icon" href="${rc.contextPath}/htdocs/images/jala.ico" type="image/x-icon" />
	<link href="${rc.contextPath}/htdocs/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/material-design-iconic-font-2.2.0/css/material-design-iconic-font.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/bootstrap-table-1.11.0/bootstrap-table.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/waves-0.7.5/waves.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/jquery-confirm/jquery-confirm.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/jquery-confirm/jquery-confirm.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/select2/css/select2.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/select2/theme/select2-bootstrap.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/webuploader-0.1.5/webuploader.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/css/common.css" rel="stylesheet"/>
	

	<link href="${rc.contextPath}/htdocs/plugins/fullPage/jquery.fullPage.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/material-design-iconic-font-2.2.0/css/material-design-iconic-font.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/waves-0.7.5/waves.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/plugins/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css" rel="stylesheet"/>
	<link href="${rc.contextPath}/htdocs/css/admin.css" rel="stylesheet"/>
	<style>
	/** skins **/
	#zheng-upms-server #header {background: #29A176;}
	#zheng-upms-server .content_tab{background: #29A176;}
	#zheng-upms-server .s-profile>a{background: url(${rc.contextPath}/htdocs/images/zheng-upms.png) left top no-repeat;}
	
	#zheng-cms-admin #header {background: #455EC5;}
	#zheng-cms-admin .content_tab{background: #455EC5;}
	#zheng-cms-admin .s-profile>a{background: url(${rc.contextPath}/htdocs/images/zheng-cms.png) left top no-repeat;}
	
	#zheng-pay-admin #header {background: #F06292;}
	#zheng-pay-admin .content_tab{background: #F06292;}
	#zheng-pay-admin .s-profile>a{background: url(${rc.contextPath}/htdocs/images/zheng-pay.png) left top no-repeat;}
	
	#zheng-ucenter-home #header {background: #6539B4;}
	#zheng-ucenter-home .content_tab{background: #6539B4;}
	#zheng-ucenter-home .s-profile>a{background: url(${rc.contextPath}/htdocs/images/zheng-ucenter.png) left top no-repeat;}
	
	#zheng-oss-web #header {background: #0B8DE5;}
	#zheng-oss-web .content_tab{background: #0B8DE5;}
	#zheng-oss-web .s-profile>a{background: url(${rc.contextPath}/htdocs/images/zheng-oss.png) left top no-repeat;}
	
	#test #header {background: test;}
	#test .content_tab{background: test;}
	#test .s-profile>a{background: url(test) left top no-repeat;}
	</style>
</head>
<body>
<div class="content_main">
	<div id="iframe_home" class="iframe cur">	
		<div id="toolbar">
			<shiro:hasPermission name="upms:system:create"><a class="waves-effect waves-button" href="javascript:;" onclick="createAction()"><i class="zmdi zmdi-plus"></i> 新增系统</a></shiro:hasPermission>
			<shiro:hasPermission name="upms:system:update"><a class="waves-effect waves-button" href="javascript:;" onclick="updateAction()"><i class="zmdi zmdi-edit"></i> 编辑系统</a></shiro:hasPermission>
			<shiro:hasPermission name="upms:system:delete"><a class="waves-effect waves-button" href="javascript:;" onclick="deleteAction()"><i class="zmdi zmdi-close"></i> 删除系统</a></shiro:hasPermission>
		</div>			
		<table id="table"></table>
	</div>
</div>
<footer id="footer"></footer>

<script src="${rc.contextPath}/htdocs/plugins/jquery.1.12.4.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/bootstrap-3.3.0/js/bootstrap.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/waves-0.7.5/waves.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/BootstrapMenu.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/device.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/fullPage/jquery.fullPage.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/fullPage/jquery.jdirk.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/jquery.cookie.js"></script>
<script src="${rc.contextPath}/htdocs/js/admin.js"></script>


<script src="${rc.contextPath}/htdocs/plugins/bootstrap-table-1.11.0/bootstrap-table.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/bootstrap-table-1.11.0/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/waves-0.7.5/waves.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/jquery-confirm/jquery-confirm.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/select2/js/select2.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/zTree_v3/js/jquery.ztree.all.min.js"></script>
<script src="${rc.contextPath}/htdocs/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script src="${rc.contextPath}/htdocs/js/common.js"></script>

<script>
var $table = $('#table');
$(function() {
	// bootstrap table初始化
	$table.bootstrapTable({
		url: 'list.do',
		striped: true,
		search: true,
		showRefresh: true,
		showColumns: true,
		minimumCountColumns: 2,
		clickToSelect: true,
		detailView: true,
		detailFormatter: 'detailFormatter',
		pagination: true,
		paginationLoop: false,
		sidePagination: 'server',
		silentSort: false,
		smartDisplay: false,
		escape: true,
		searchOnEnterKey: true,
		idField: 'systemId',
		maintainSelected: true,
		toolbar: '#toolbar',
		columns: [
			{field: 'ck', checkbox: true},
			{field: 'systemId', title: '编号', sortable: true, align: 'center'},
			{field: 'icon', title: '图标', sortable: true, align: 'center', formatter: 'iconFormatter'},
            {field: 'title', title: '系统标题'},
			{field: 'name', title: '系统名称'},
			{field: 'basepath', title: '根目录'},
			{field: 'status', title: '状态', sortable: true, align: 'center', formatter: 'statusFormatter'},
			{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
		]
	});
});
// 格式化操作按钮
function actionFormatter(value, row, index) {
    return [
        '<a class="update" href="javascript:;" onclick="updateAction()" data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>　',
        '<a class="delete" href="javascript:;" onclick="deleteAction()" data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>'
    ].join('');
}
// 格式化图标
function iconFormatter(value, row, index) {
    return '<i class="' + value + '"></i>';
}
// 格式化状态
function statusFormatter(value, row, index) {
	if (value == 1) {
		return '<span class="label label-success">正常</span>';
	} else {
		return '<span class="label label-default">锁定</span>';
	}
}
// 新增
var createDialog;
function createAction() {
	createDialog = $.dialog({
		animationSpeed: 300,
		title: '新增系统',
		content: 'url:${basePath}/manage/system/create',
		onContentReady: function () {
			initMaterialInput();
			initUploader();
		}
	});
}
// 编辑
var updateDialog;
function updateAction() {
	var rows = $table.bootstrapTable('getSelections');
	if (rows.length != 1) {
		$.confirm({
			title: false,
			content: '请选择一条记录！',
			autoClose: 'cancel|3000',
			backgroundDismiss: true,
			buttons: {
				cancel: {
					text: '取消',
					btnClass: 'waves-effect waves-button'
				}
			}
		});
	} else {
		updateDialog = $.dialog({
			animationSpeed: 300,
			title: '编辑系统',
			content: 'url:${basePath}/manage/system/update/' + rows[0].systemId,
			onContentReady: function () {
				initMaterialInput();
				initUploader();
			}
		});
	}
}
// 删除
var deleteDialog;
function deleteAction() {
	var rows = $table.bootstrapTable('getSelections');
	if (rows.length == 0) {
		$.confirm({
			title: false,
			content: '请至少选择一条记录！',
			autoClose: 'cancel|3000',
			backgroundDismiss: true,
			buttons: {
				cancel: {
					text: '取消',
					btnClass: 'waves-effect waves-button'
				}
			}
		});
	} else {
		deleteDialog = $.confirm({
			type: 'red',
			animationSpeed: 300,
			title: false,
			content: '确认删除该系统吗？',
			buttons: {
				confirm: {
					text: '确认',
					btnClass: 'waves-effect waves-button',
					action: function () {
						var ids = new Array();
						for (var i in rows) {
							ids.push(rows[i].systemId);
						}
						$.ajax({
							type: 'get',
							url: '${basePath}/manage/system/delete/' + ids.join("-"),
							success: function(result) {
								if (result.code != 1) {
									if (result.data instanceof Array) {
										$.each(result.data, function(index, value) {
											$.confirm({
												theme: 'dark',
												animation: 'rotateX',
												closeAnimation: 'rotateX',
												title: false,
												content: value.errorMsg,
												buttons: {
													confirm: {
														text: '确认',
														btnClass: 'waves-effect waves-button waves-light'
													}
												}
											});
										});
									} else {
										$.confirm({
											theme: 'dark',
											animation: 'rotateX',
											closeAnimation: 'rotateX',
											title: false,
											content: result.data.errorMsg,
											buttons: {
												confirm: {
													text: '确认',
													btnClass: 'waves-effect waves-button waves-light'
												}
											}
										});
									}
								} else {
									deleteDialog.close();
									$table.bootstrapTable('refresh');
								}
							},
							error: function(XMLHttpRequest, textStatus, errorThrown) {
								$.confirm({
									theme: 'dark',
									animation: 'rotateX',
									closeAnimation: 'rotateX',
									title: false,
									content: textStatus,
									buttons: {
										confirm: {
											text: '确认',
											btnClass: 'waves-effect waves-button waves-light'
										}
									}
								});
							}
						});
					}
				},
				cancel: {
					text: '取消',
					btnClass: 'waves-effect waves-button'
				}
			}
		});
	}
}
</script>

</body>
</html>